package inter

import (
	"fmt"
)

/**
 * 空接口定义
 */
func emptyInterface01() {
	// 	var i interface{}
	// 	i = 10
	// 	printInterface(i)
	// 	i = "abc"
	// 	printInterface(i)
	// 	i = false
	// 	printInterface(i)
	a := 10
	b := "abc"
	c := true
	printInterface(a, b, c)
}

func printInterface(key ...interface{}) {
	//fmt.Printf("type: %T, value :%v \n", key, key)
	for _, v := range key {
		fmt.Printf("type: %T, value :%v \n", v, v)
	}
}

func emptyInterface02() {
	any := make([]interface{}, 5)
	any[0] = 11
	any[1] = "hello world"
	any[2] = []int{11, 22, 33, 44}
	for _, value := range any {
		fmt.Println(value)
	}
}

/**
 * 类型打印
 */
func printType(i interface{}) {
	switch i.(type) {
	case int:
		fmt.Println("type is int")
	case string:
		fmt.Println("type is string")
	}
}
